home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-17 | 2.7 KB | 128 lines | [TEXT/MMCC] |
- #include "CPrefDialog.h"
- #include "MPDialogs.h"
-
- StPrefDialog::StPrefDialog(LCommander *inSuper, ResIDT inMenu, ResIDT inDialogID, Handle &ioHandle)
- : LCommander(inSuper)
- {
- HiliteMenu(inMenu);
- mPrefsDialog =
- OpenMPDialog(inDialogID, nil, nil, nil, nil, &ioHandle);
-
- mMessage = msg_Nothing;
- mSleepTime = 6;
-
- SwitchTarget(this);
- }
-
- StPrefDialog::~StPrefDialog()
- {
- if (mPrefsDialog) CloseMPDialog(&mPrefsDialog);
- LView::OutOfFocus(nil);
- HiliteMenu(0);
- }
-
- MessageT
- StPrefDialog::DoDialog()
- {
- EventRecord macEvent;
- short result;
-
- SetUpdateCommandStatus(true);
- UpdateMenus();
-
- if (IsOnDuty()) {
- ::OSEventAvail(0, &macEvent);
- AdjustCursor(macEvent);
- }
-
- while (mPrefsDialog) {
- Boolean gotEvent = ::WaitNextEvent(everyEvent, &macEvent, mSleepTime, mMouseRgnH);
- mMessage = msg_Nothing;
-
- if (DoMPDialogEvent(&mPrefsDialog, &macEvent, &result)) {
- if (!mPrefsDialog) switch (result) {
- case kNotClosed:
- case kCancelClosed:
- return cmd_Nothing;
- case kOKClosed:
- return cmd_Save;
- }
- }
-
- switch (macEvent.what) {
- case autoKey:
- case keyUp:
- case keyDown:
- continue;
- }
-
- if (LEventDispatcher::ExecuteAttachments(msg_Event, &macEvent)) {
- if (gotEvent) {
- DispatchEvent(macEvent);
- } else {
- UseIdleTime(macEvent);
- }
- }
-
- LPeriodical::DevoteTimeToRepeaters(macEvent);
- }
-
- if (IsOnDuty() && GetUpdateCommandStatus()) {
- UpdateMenus();
- }
-
- return mMessage;
- }
-
- void
- StPrefDialog::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean& /* outUsesMark */,
- Char16& /* outMark */,
- Str255 /* outName */)
- {
- // Don't enable any commands except cmd_About, which will keep
- // the Apple menu enabled. This function purposely does not
- // call the inherited FindCommandStatus, thereby suppressing
- // commands that are handled by SuperCommanders. Only those
- // commands enabled by SubCommanders will be active.
-
- outEnabled = false;
- if (inCommand == cmd_About) {
- outEnabled = true;
- }
- }
-
- void
- StPrefDialog::EventMouseDown(const EventRecord &inMacEvent)
- {
- WindowPtr macWindowP;
- Int16 thePart = ::FindWindow(inMacEvent.where, &macWindowP);
-
- switch (thePart) {
-
- case inContent:
- LCommander::SetUpdateCommandStatus(true);
- // Fall Thru
- case inDrag:
- case inGrow:
- case inGoAway:
- case inZoomIn:
- case inZoomOut:
- if (macWindowP != ::FrontWindow() && mPrefsDialog) {
- // Front Window is Modal
- if ( (thePart != inDrag) || !(inMacEvent.modifiers & cmdKey) ) {
- // Dispatch click to Window object
- LWindow *theWindow = LWindow::FetchWindowObject(macWindowP);
- if (theWindow != nil) {
- theWindow->HandleClick(inMacEvent, click_OutsideModal);
- return;
- }
- }
- }
- break;
- }
- LEventDispatcher::EventMouseDown(inMacEvent);
- }
-